/*
 * Rhy Browser Core Lib
 * 
 * @author Tristan Maindron
 * 
 */

Rhy.browser = {
    
    getStartPos:function(){
        return navigator.userAgent.substring(0, navigator.userAgent.indexOf("(", 0));
    },
    
	getMidPos:function(){
        var ua = navigator.userAgent;
        return ua.substring(ua.indexOf("(", 0), ua.indexOf(")", 0));
    },
    
	getEndPos:function(){
        return navigator.userAgent.substring(navigator.userAgent.indexOf(")", 0));
    },
    
	isInternetExplorer:function(){
        return (this.getMidPos().indexOf("MSIE") != -1);
    },
    
	isSafari:function(){
        var safari = (this.getEndPos().indexOf("Safari") != -1);
        var notChrome = this.isChrome();
        return !notChrome && safari;
    },
    
	isFirefox:function(){
        return (this.getEndPos().indexOf("Firefox") != -1);
    },
    
	isChrome:function(){
        return (this.getEndPos().indexOf("Chrome") != -1);
    },
    
    getIExplorerVersion: function(){
        if (!Rhy.browser.isInternetExplorer()) {
            return 0;
        } else {
            var ua = navigator.userAgent;
            var ms = ua.indexOf("MSIE ");
            return parseFloat(ua.substring(ms + 5, ua.indexOf(";", ms)));
        }
    }
};

